package com.windrift.ws.order.client;

import com.windrift.ws.order.Order;
import com.windrift.ws.order.OrderProcess;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;

/**
 * Created by IntelliJ IDEA.
 * User: cy
 * Date: 10/05/12
 * Time: 9:46 PM
 * To change this template use File | Settings | File Templates.
 */
public class ClientWithoutSpring {
    private static final QName SERVICE_NAME =
            new QName("http://order.demo/", "OrderProcessImplService");
    private static final QName PORT_NAME =
            new QName("http://order.demo/", "OrderProcessServicePort");
    private static final String WSDL_LOCATION =
            "http://localhost:8080/orderapp/OrderProcess?wsdl";
    public static void main(String args[]) throws Exception {
        URL wsdlURL = new URL(WSDL_LOCATION);
        Service service = Service.create(wsdlURL, SERVICE_NAME);
        OrderProcess port = service.getPort(PORT_NAME,
                OrderProcess.class);
        Order order = new Order();
        order.setCustomerId("C001");
        order.setItemId("I001");
        order.setPrice(100.00);
        order.setQty(20);
        String result = port.processOrder(order);
        System.out.println("The order ID is " + result);
    }
}
